/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                                                  *
 *        *************************************************         *
 *        *©2021-2027 HT Corporation All rights reserved *          *
 *        *************************************************         *
 *                                                                  *
 * FileName    : h_vi.c                                             *
 *                                                                  *
 * Author      : linus                                              *
 *                                                                  *
 * Email       : luoyaojun@haitutech.com                            *
 *                                                                  *
 * Date        : 2022-8-9                                           *
 *                                                                  *
 * Description :                                                    *
 *                                                                  *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h_vi.h"
#include "h_register.h"
#include "ht_type.h"
#include "ht_vi.h"

HT_S32 ht_vi_dev_init(HT_S32 viDev)
{
	struct ht_vi_config *pconfig = NULL;
    struct ht_vi *pvi = HT_MPP_HANDLE_VI;
    HT_S32 ret = -1;

    if (pvi && pvi->ops && pvi->ops->vi_dev_init)
        ret = pvi->ops->vi_dev_init(pvi, viDev);

    return ret;
}

HT_S32 ht_vi_get_connection_info(HT_U32 viDev, HT_U32 viChn, struct ht_vi_connection_info *conn_info)
{
    struct ht_vi *pvi = HT_MPP_HANDLE_VI;
    HT_S32 ret = -1;

	if (!conn_info)
		return -1;

	conn_info->viDev = viDev;
	conn_info->viChn = viChn;

	if (pvi && pvi->ops && pvi->ops->vi_get_connecion_info)
        ret = pvi->ops->vi_get_connecion_info(pvi, conn_info);

	return ret;
}

HT_S32 ht_vi_dev_exit(HT_U32 viDev)
{
    struct ht_vi *pvi = HT_MPP_HANDLE_VI;
    HT_S32 ret = -1;

	if (pvi && pvi->ops && pvi->ops->vi_dev_exit)
        ret = pvi->ops->vi_dev_exit(pvi, viDev);
	
    return ret;
}

HT_S32 ht_vi_chn_init(HT_U32 viDev, HT_U32 viChn, struct ht_vi_config *pinfo)
{
    struct ht_vi *pvi = HT_MPP_HANDLE_VI;
    HT_S32 ret = -1;

	if (!pinfo)
		return -1;
	
	if (pvi && pvi->ops && pvi->ops->vi_chn_init)
        ret = pvi->ops->vi_chn_init(pvi, viDev, viChn, pinfo);

    return ret;
}

HT_S32 ht_vi_chn_exit(HT_U32 viDev, HT_U32 viChn)
{
    struct ht_vi *pvi = HT_MPP_HANDLE_VI;
    HT_S32 ret = -1;

    if (!pvi)
        return -1;

	if (pvi && pvi->ops && pvi->ops->vi_chn_exit)
        ret = pvi->ops->vi_chn_exit(pvi, viDev, viChn);

    return ret;
}

HT_S32 ht_vi_chn_get_frame(HT_U32 viDev, HT_U32 viChn, HT_S32 wait_time, ht_vi_get_frame_cb cb, void *user)
{
    struct ht_vi *pvi = HT_MPP_HANDLE_VI;
    HT_S32 ret = -1;

    if (pvi && pvi->ops && pvi->ops->vi_chn_get_frame)
        ret = pvi->ops->vi_chn_get_frame(pvi, viDev, viChn, wait_time, cb, user);

    return ret;
}

HT_S32 ht_vi_chn_stop_frame(HT_U32 viDev, HT_U32 viChn)
{
    struct ht_vi *pvi = HT_MPP_HANDLE_VI;
    HT_S32 ret = -1;

    if (pvi && pvi->ops && pvi->ops->vi_chn_stop_frame)
        ret = pvi->ops->vi_chn_stop_frame(pvi, viDev, viChn);

    return ret;
}

HT_U64 ht_vi_frame_get_pts(HT_FRAME frame)
{
    struct ht_vi *pvi = HT_MPP_HANDLE_VI;
    HT_S32 ret = -1;

	if (!frame)
		return 0;
	
    if (pvi && pvi->ops && pvi->ops->vi_frame_get_pts)
        ret = pvi->ops->vi_frame_get_pts(pvi, frame);
	
	
}

HT_S32 ht_vi_modules_register(struct ht_vi *pvi)
{
    return (ht_register_modules(pvi->m_id, (HT_HANDLE)pvi));
}

